#
# $Id: tc_descriptor_type.rb 4 2007-09-27 09:38:28Z dinko.srkoc $
#

require 'test/unit'
require 'genus/descriptor_type'

# +DescriptorType+ module tests
class TC_DescriptorType < Test::Unit::TestCase
  
  # Tests for existence of modules which should implement given descriptor type.
  # Descriptor types are enumerated in <tt>DESCRIPTOR_TYPE</tt> array.
  def test_descriptor_modules
    DESCRIPTOR_TYPES.each do |dt|
      dm = DescriptorType::descriptor_module(dt)
      assert_equal(true, DescriptorType.constants.include?(dm.name.sub(/^DescriptorType::/, '')))
    end
    assert_raise(RuntimeError) { DescriptorType::descriptor_module(:unknown) }
  end
  
  # Each module associated with given descriptor type must implement
  # <tt>make_descriptor</tt> method (which in being used by the instance
  # of the +PersistenceDescriptorGenerator+ class).
  def test_existence_make_descriptor
    DESCRIPTOR_TYPES.each do |dt|
      extend DescriptorType::descriptor_module(dt)
      assert_respond_to(self, :make_descriptor)
    end
  end
  
end
